using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Workshops.Queries;

/// <summary>
/// 查询车间命令。
/// </summary>
public record GetWorkshopListQuery : IRequest<IResult<List<MdWorkshopDto>>>;

internal sealed class GetWorkshopListQueryHandler(IRepository<MdWorkshop> repo) : IRequestHandler<GetWorkshopListQuery, IResult<List<MdWorkshopDto>>>
{
    public async Task<IResult<List<MdWorkshopDto>>> Handle(GetWorkshopListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(cancellationToken);
        return Result.From(items.Adapt<List<MdWorkshopDto>>());
    }
}
